package cn.itcast.service.impl;

import cn.itcast.dao.MemberDao;
import cn.itcast.entity.PageResult;

import cn.itcast.entity.QueryPageBean;
import cn.itcast.entity.Result;
import cn.itcast.pojo.Member;
import cn.itcast.service.MemberService;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.List;


import cn.itcast.pojo.Member;
import cn.itcast.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberDao memberDao;
    @Override
    public List<Member> findAll() {

        return memberDao.findAll();
    }

    @Override
    public Member findById(Integer id) {
        

        return memberDao.findById(id);
    }

    @Override
    public void add(Member member) {

       memberDao.add(member);

    }


    @Override
    public PageResult pageQuery(Integer currentPage, Integer pageSize,String QueryString) {
        PageHelper.startPage(currentPage, pageSize);
        Page<Member> page = memberDao.selectByCondition(QueryString);
        return new PageResult(page.getTotal(), page.getResult());

    }

    @Override
    public Integer update(Member member) {
      return   memberDao.update(member);

    }

    @Override
    public Boolean updateStatus(Integer id, Integer status) {


    return   memberDao.updateStatus(id, status)>0;
    }



    /**
     * 根据手机号查询会员信息
     * @param phone
     * @return
     */
    @Override
    public Member findByTelephone(String phone) {

        return memberDao.findByTelephone(phone);
    }

    /**
     * 添加会员信息
     * @param member
     */
//    @Override
//    public void add(Member member) {
//        memberDao.add(member);
//
//    }
}
